<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  #box{
    width: 150px;
    height: 150px;
    background-color: pink;
  }
</style>
<body>
  <div id="box">盒子</div>
  <button id="btn" onclick="b()">点击改变盒子大小</button>
  <script>
    var box = document.getElementById('box')
    var btn = document.getElementById('btn')
    function b(){
      box.style.width = '50px'
      box.style.height = '50px'
    }
  </script>
</body>
</html>